<template>
	<view>
		<view class="swiper">
			<swiper class="swiper-box" circular :indicator-dots="false" :autoplay="true" :interval="8000"
				:duration="500" @change="change">
				<swiper-item v-for="it in bannerList">
					<image :src="it.cover" mode="aspectFill"></image>
				</swiper-item>
				<!-- <swiper-item>
					<image src="https://picsum.photos/750/631?2" mode=""></image>
				</swiper-item>
				<swiper-item>
					<image src="https://picsum.photos/750/631?3" mode=""></image>
				</swiper-item> -->
			</swiper>
			<view class="dots flex-center">
				<view :class="index === currentBanner ? 'dots-item dots-item-ac' : 'dots-item'" v-for="(it,index) in bannerList.length"></view>
			</view>
			<view class="search">
				<input type="text" placeholder="请输入关键词" placeholder-class="ac">
				<image :src="mixiImgUrl + '/static/搜索.png'" mode=""></image>
			</view>
		</view>
		<view class="content">
			<view class="card">
				<view class="card-item flex-center" v-for="it in tabList">
					<image :src="mixiImgUrl + it.img" mode=""></image>
					{{it.label}}
				</view>
			</view>
			<view class="member">
				<image :src="mixiImgUrl + '/static/huiybj.png'" mode=""></image>
				<view class="member-content flex-sp">
					<view class="member-l">
						<view class="member-l-title">成为创谱会员</view>
						<view class="member-l-subTitle">家谱唯一的领头续修家谱人</view>
					</view>
					<view class="member-content-r flex-center" @click="toMember">立即申请</view>
				</view>
			</view>
			<view class="more flex-sp">
				<view class="more-l">猜你喜欢</view>
				<view class="more-r flex-center">
					查看更多
					<view>
						<u-icon name="arrow-right" color="#BBBBBB" size="14"></u-icon>
					</view>
					
				</view>
			</view>
			<view class="list">
				<view class="list-item" v-for="it in list" @click="toDetail(it)">
					<view class="list-item-l">
						<image :src="it.img" mode="aspectFill"></image>
					</view>
					<view class="list-item-r">
						<view class="list-item-r-title">《{{it.name}}》</view>
						<view class="list-item-r-address">原籍地址:{{it.address || ''}}</view>
						<view class="list-item-r-num flex-center">
							<image src="/static/浏览.png" mode=""></image>
							<text>浏览量：{{it.view_num || 0}}</text>
						</view>
					</view>
				</view>
			</view>
			<u-gap :height="15"></u-gap>
		</view>
	</view>
</template>

<script>
	import {indexHttp} from '@/common/http/api.js'
	const config = require('@/common/config.js')
	export default {
		data() {
			return {
				bannerList: [],
				currentBanner: 0,
				tabList: [
					{
						label: '寻根问祖',
						img: '/static/xungenwz.png'
					},
					{
						label: '创建家谱',
						img: '/static/chuanjjiap.png'
					},
					{
						label: '追思拜祭',
						img: '/static/zuisi.png'
					},
					{
						label: '家谱商城',
						img: '/static/lsc.png'
					},
					{
						label: '健康管理',
						img: '/static/lianxiwom.png'
					}
				],
				list: []
				
			};
		},
		
		onLoad() {
			this.init()
			
		},
		onShow() {
			
		},
		methods: {
			toDetail(it){
				uni.navigateTo({
					url:'/pages/genealogy/detail/tree?id=' + it.id
				})
			},
			toMember(){
				uni.navigateTo({
					url:'/pages/member/member'
				})
			},
			change(e){
				this.currentBanner = e.detail.current
			},
			init() {
				indexHttp().then(res=>{
					this.bannerList = res.data.bannerList
					this.list = res.data.genealogyList
				})
			}
		}
	};
</script>

<style lang="scss">
	.swiper {
		width: 100%;
		height: 631rpx;
		position: fixed;
		top: 0;
		left: 0;
		z-index: -2;
		.swiper-box {
			width: 100%;
			height: 100%;
		}
		.dots {
			width: 100%;
			height: 18rpx;
			position: absolute;
			bottom: 80rpx;
			left: 50%;
			transform: translateX(-50%);
			margin: auto;
			.dots-item {
				width: 18rpx;
				height: 18rpx;
				background: #FFFFFF;
				border-radius: 50%;
				margin-right: 14rpx;
				opacity: 0.4;
			}
			.dots-item-ac {
				opacity: 1;
			}
			.dots-item:last-child {
				margin-right: 0;
			}
		}
		.search {
			width: 686rpx;
			height: 78rpx;
			background: rgba(255,255,255,0.25);
			border-radius: 39rpx;
			position: absolute;
			bottom: 140rpx;
			left: 50%;
			transform: translateX(-50%);
			margin: auto;
			display: flex;
			align-items: center;
			input {
				min-width: 0;
				flex: 1;
				box-sizing: border-box;
				padding: 0 30rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				font-size: 30rpx;
				color: #FFFFFF;
			}
			.ac {
				font-family: Source Han Sans CN;
				font-weight: 400;
				font-size: 30rpx;
				color: #FFFFFF;
			}
			image {
				width: 66rpx;
				height: 66rpx;
			}
		}
	}
	.content {
		margin-top: 631rpx;
		width: 100%;
		min-height: calc(100vh - 631rpx);
		background: #F6F1E7;
		position: relative;
	}
	.content::after {
		width: 100%;
		content: "";
		position: absolute;
		top: -40rpx;
		left: 0;
		height: 40rpx;
		background: #F6F1E7;
		border-top-right-radius: 40rpx;
		border-top-left-radius: 40rpx;
		
	}
	.card {
		width: 100%;
		box-sizing: border-box;
		padding: 0 52rpx;
		display: grid;
		grid-template-columns: repeat(5,1fr);
		grid-gap: 43rpx;
		margin-bottom: 30rpx;
		.card-item {
			flex-direction: column;
			image {
				width: 95rpx;
				height: 95rpx;
				margin-bottom: 7rpx;
			}
			font-family: Source Han Sans CN;
			font-weight: 500;
			font-size: 22rpx;
			color: #333333;
		}
	}
	.member {
		width: 690rpx;
		margin: 0 auto;
		height: 200rpx;
		position: relative;
		margin-bottom: 30rpx;
		.member-content {
			width: 100%;
			height: 100%;
			position: absolute;
			top: 0;
			left: 0;
			box-sizing: border-box;
			padding: 0 30rpx;
			.member-l {
				.member-l-title {
					font-family: CTBiaoSongSJ;
					font-weight: 400;
					font-size: 36rpx;
					color: #EFC882;
					margin-bottom: 14rpx;
					font-weight: bold;
				}
				.member-l-subTitle {
					font-family: Source Han Sans CN;
					font-weight: 400;
					font-size: 24rpx;
					color: #9D8366;
				}
			}
			.member-content-r {
				width: 162rpx;
				height: 64rpx;
				background: linear-gradient(-38deg, #EFC882, #FFE2AB);
				border-radius: 10rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				font-size: 30rpx;
				color: #443D36;
			}
		}
	}
	.more {
		margin: 0 auto;
		margin-bottom: 20rpx;
		width: 690rpx;
		.more-l {
			font-family: Source Han Sans CN;
			font-weight: 500;
			font-size: 36rpx;
			color: #333333;
		}
		.more-r {
			font-family: Source Han Sans CN;
			font-weight: 400;
			font-size: 24rpx;
			color: #999999;
			view {
				margin-left: 5rpx;
			}
		}
	}
	.list {
		margin: 0 auto;
		paddomg-bottom: 20rpx;
		width: 690rpx;
		.list-item {
			width: 690rpx;
			background: #FFFFFF;
			border-radius: 24rpx;
			box-sizing: border-box;
			padding: 20rpx 26rpx;
			display: flex;
			margin-bottom: 20rpx;
			.list-item-l {
				width: 126rpx;
				height: 173rpx;
				margin-right: 24rpx;
			}
			.list-item-r {
				flex: 1;
				.list-item-r-title {
					font-family: Source Han Sans CN;
					font-weight: 500;
					font-size: 32rpx;
					color: #333333;
					margin-bottom: 19rpx;
				}
				.list-item-r-address {
					font-family: Source Han Sans CN;
					font-weight: 400;
					font-size: 26rpx;
					color: #999999;
					margin-bottom: 28rpx;
				}
				.list-item-r-num {
					width: fit-content;
					box-sizing: border-box;
					padding: 12rpx 21rpx;
					height: 47rpx;
					background: #F8F8F8;
					border-radius: 8rpx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					font-size: 24rpx;
					color: #999999;
					image {
						width: 28rpx;
						height: 17rpx;
					}
				}
			}
		}
	}
</style>